<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/_template.xhtml">
	<ui:define name="content">
	<div id="tree">
		<h:form>
			<p:tree value="#{treeBean.root}" var="doc" id="tree">
				<p:treeNode expandedIcon="ui-icon-folder-open"
					collapsedIcon="ui-icon-folder-collapsed">
					<h:outputText value="#{doc}" />
				</p:treeNode>

				<p:treeNode type="document" icon="ui-icon-document">
					<h:outputText value="#{doc}" />
				</p:treeNode>
			</p:tree>
		</h:form>
	</div>
	<div id="content">
		<h:form id="busca-form">
			<fieldset>
			    <legend>Consultar Tipo de Documento</legend>
			    <h:panelGrid columns="2">		
			    	<h:outputLabel for="nome">Nome do Tipo de Documento:</h:outputLabel>		
					<p:inputText id="search-query" value="#{listaTipoDocumentoBean.chave}"/>
					<p:commandButton id="pesquisar" value="Pesquisar" action="#{listaTipoDocumentoBean.pesquisar}"/>
				</h:panelGrid>
			</fieldset>
		</h:form>
		<h:form>
			<p:dataTable value="#{listaTipoDocumentoBean.dataModel}"
				var="tipoDocumento" paginator="true" rows="5" dynamic="true" lazy="true">

				<p:column headerText="Nome">
					#{tipoDocumento.nome}
				</p:column>

				<p:column headerText="Símbolo">
					#{tipoDocumento.simbolo}
				</p:column>
				
				<p:column headerText="Qtde Doc Relacionados">
					 #{listaTipoDocumentoBean.quantidadeDocumentos(tipoDocumento)}
				</p:column>
				
				<p:column headerText="Alterar">
					<h:commandLink action="#{tipoDocumentoBean.alterar(tipoDocumento)}"
						value="Alterar" />
				</p:column>
				
				<p:column headerText="Excluir">
					<h:commandLink action="#{listaTipoDocumentoBean.deletar(tipoDocumento)}"
						value="Excluir" />
				</p:column>
				
			</p:dataTable>
			<p:messages id="messages" showDetail="true" autoUpdate="true" />
		</h:form>
	</div>
	</ui:define>
</ui:composition>


</html>